﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using spk_eAuction.Classes;
namespace spk_eAuction.Paypal
{
    public partial class expresscheckout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            NVPAPICaller test = new NVPAPICaller();
            string retMsg = "";
            string token = "";

            if (HttpContext.Current.Session["payment_amt"] != null)
            {
                string amt = HttpContext.Current.Session["payment_amt"].ToString();

                //Optional Shipping Address entered on the merchant site
                string shipToName = "<SHIPTONAME>";
                string shipToStreet = "<SHIPTOSTREET>";
                string shipToStreet2 = "<SHIPTOSTREET2>";
                string shipToCity = "<SHIPTOCITY>";
                string shipToState = "<SHIPTOSTATE>";
                string shipToZip = "<SHIPTOCITY>";
                string shipToCountryCode = "<SHIPTOCOUNTRYCODE>";

                bool ret = test.MarkExpressCheckout(amt, shipToName, shipToStreet, shipToStreet2,
                                shipToCity, shipToState, shipToZip, shipToCountryCode,
                                ref token, ref retMsg);

                //            bool ret = test.ShortcutExpressCheckout(amt, ref token, ref retMsg);
                if (ret)
                {
                    HttpContext.Current.Session["token"] = token;
                    Response.Redirect(retMsg);
                }
                else
                {
                    Response.Redirect("~/Paypal/APIError.aspx?" + retMsg);
                }
            }
            else
            {
                Response.Redirect("~/Paypal/APIError.aspx?ErrorCode=AmtMissing");
            }
        }
    }
}